package com.schooldate.model.service.impl;

import com.schooldate.base.BaseSupportImpl;
import com.schooldate.model.entity.MessageBoardReply;
import com.schooldate.model.service.MessageBoardReplyService;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by etund on 2015/3/30 0030.
 */
@Service
@Transactional
@SuppressWarnings("all")
public class MessageBoardReplyServiceImpl extends BaseSupportImpl<MessageBoardReply> implements MessageBoardReplyService {

    @Override
    public List<MessageBoardReply> getByMessageBoardId(Integer maxNum, Long messageBoardId) {
        System.out.println(maxNum+messageBoardId+"==============test============");
        return this.getSession().createCriteria(MessageBoardReply.class)
                        .add(Restrictions.eq("messageBoard.id", messageBoardId))
                        .addOrder(Order.desc("id"))
                        .setMaxResults(maxNum)
                        .list();
    }
}
